$(function () {
    // 获取关注列表
    var loading = weui.loading('loading', {
        className: 'custom-classname'
    });
    var result = Model.user.getMyAttention({});
    for (var i = 0; i < result.us.length; i++) {
        var item = ' <div class="weui-cell">' +
            '            <div class="shop-vendor-left" userid="'+result.us[i].userid+'">' +
            '                <div class="portrait-block">' +
            '                    <img class="portrait-img"' +
            '                         src="'+result.us[i].photo+'">' +
            '                </div>' +
            '            </div>' +
            '            <div class="weui-cell__bd">' +
            '                <h3 class="text-1-4 username">'+result.us[i].nickname+'</h3>' +
            '            </div>' +
            '            <div class="weui-cell__ft">' +
            '                <a href="javascript:;" class="weui-btn weui-btn_mini weui-btn_default attention-btn" userid="'+result.us[i].userid+'">取消关注</a>' +
            '            </div>' +
            '        </div>'
        $(".list-concerns").append(item);
    }
    loading.hide();
});



$(document).on('click', '.attention-btn', function () {
    var t_userid = $(this).attr("userid");

    var confirms = weui.confirm(
        "真的要取消关注吗？",
        function () {
            // 取消关注
            var result = Model.business.attendBusiness({
                t_userid: t_userid
            })
            location.reload();
        },
        function () {
        }
    );


})
$(document).on("mousedown", ".cancel-concerns", function (event) {
    var id = $(this).attr("data-id"),
        result = '';
    var confirms = weui.confirm(
        "真的要取消关注吗？",
        function () {
            // 取消关注
            result = Model.business.attendBusiness({
                businessId: id
            });
            if (result.code) {
                alert(result.message);
                location.reload();
                return false;
            }
            location.reload();
        },
        function () {
        }
    );
});

$(document).on("click", ".shop-vendor-left", function () {
    var id = $(this).attr("userid");
    location.href = "shop_detail.html?id=" + id;
});